const mongoose = require('mongoose')
const {formatDate} = require('../../utils')
const userSchema = new mongoose.Schema({
    username: { type: String, required: true, unique:true, minlength: 3, maxlength: 12, trim: true },
    phone: { type: String, required: true, unique:true },
    password: { type: String, required: true, trim: true },
    ctime: { type: String, required: true, default: formatDate() },
    role: { type: Number, required: true, default: 2, min: 1, max: 3 }, //1管理员 2普通用户 3超级游客
    status: {type: Number, required: true, default: 1, min: 1, max: 2 } //1正常 2禁用
})

const User = mongoose.model('user', userSchema)

module.exports = User